package com.yinhe.music.yhmusic.search.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yinhe.music.common.GlideHelper.GlideHelper;
import com.yinhe.music.common.utils.KeywordUtil;
import com.yinhe.music.yhmusic.R;
import com.yinhe.music.yhmusic.model.SongMenuList;

import java.util.List;

/**
 *
 * @author hasee
 * @date 2017/8/15
 */

public class MenuAdapter extends BaseQuickAdapter<SongMenuList, BaseViewHolder> {
    private String key;

    public MenuAdapter(@Nullable List<SongMenuList> data,String key) {
        super(R.layout.fav_album_item, data);
        this.key = key;
    }

    public void setSearchKey(String key) {
        this.key = key;
    }

    @Override
    protected void convert(BaseViewHolder helper, SongMenuList item) {
        helper.setText(R.id.album_name,item.getSongMenuName());
            helper.setText(R.id.album_num,item.getSongNum() + "首， 播放" + item.getPlay())
            .setGone(R.id.album_frame,false);
        ImageView image = helper.getView(R.id.album_image);
        GlideHelper.setImageResource(image,item.getImage(),R.drawable.default_cover);
        if (key != null) {
            helper.setText(R.id.album_name, KeywordUtil.matcherSearchTitle(Color.parseColor("#1d89ff"),item.getSongMenuName(),key));
        }
    }
}
